﻿@{
    ViewBag.Title = "M_ZSymptomPendingInvestigationList";
    Layout = "~/Areas/IM/Views/Shared/_Layout.cshtml";
}
@section Scripts{
    <script type="text/javascript">
        window.ondragstart = function () { window.event.returnValue = false; }
        window.oncontextmenu = function () { window.event.returnValue = false; }
        window.onselectstart = function () { event.returnValue = false; }
        var ParentSymptomCode;
        var ParentLevelCode;
        var ParentName;
        var LowerLevelSymptomCode;
        var LowerLevelCode;
        var LowerName;
        var Isac;
     
        $(document).ready(function () {
            initTree();
            $.setDivOnly("#TableForm");
        });
        $(window).resize(function () {
            $.setDivOnly("#TableForm");
        });
        function initTree() {
            $('#M_ZSymptomPendingInvestigationTree').tree({
                url: '@Url.Content("~/DM/M_ZSymptomPendingInvestigation/DataLoad")',
                method: 'POST',
                animate: true,
                lines: true,
                onContextMenu: function (e, node) {
                    e.preventDefault();
                    // 查找节点
                    $('#M_ZSymptomPendingInvestigationTree').tree('select', node.target);
                    var pnode = $('#M_ZSymptomPendingInvestigationTree').tree('getParent', node.target);
                    if (pnode != null) {
                        ParentSymptomCode = pnode.id;
                        ParentName = pnode.text;
                    } else {
                        ParentSymptomCode = 0;
                        ParentName = "无";
                    };
                        LowerLevelSymptomCode = node.id;
                        LowerName = node.text;
                        // 显示快捷菜单
                        $('#menu').menu('show', {
                            left: e.pageX,
                            top: e.pageY
                        });
                },
                formatter: function (node) {
                    if (node.attributes.isAtion == false) {
                        return '<span style="color:red">' + node.text + '</span>';
                    } else {
                        return node.text;
                    }
                }
            });
        }
       
        function AddSymptomLevel() {
            $.GID("btnadd").style.display = "block";
            $.GID("btnedit").style.display = "none";
            $('#ParentSymptom').textbox('setText', ParentName);
            $('#ParentID').val(ParentSymptomCode)
            $('#Symptom').textbox('clear');
            $('#IsActive').combobox('setText',"有效" );
            $('#SN').textbox('setValue', 255);
            $('#PinYin').textbox('clear');
            $('#M_ZSymptomPendingInvestigationEdit').dialog('open');
            $('#btnadd').linkbutton('enable');
        }
        function AddSymptomLowerLevel() {
            $.GID("btnadd").style.display = "block";
            $.GID("btnedit").style.display = "none";
            $('#ParentSymptom').textbox('setText', LowerName);
            $('#ParentID').val(LowerLevelSymptomCode);
            $('#SN').textbox('setValue', 255);
            $('#IsActive').combobox('setText', "有效");
            $('#PinYin').textbox('clear');
            $('#Symptom').textbox('clear');
            $('#M_ZSymptomPendingInvestigationEdit').dialog('open');
            $('#btnadd').linkbutton('enable');
        }
        function EditSymptomInfo() {

            $.GID("btnadd").style.display = "none";
            $.GID("btnedit").style.display = "block";
            $('#ParentSymptom').textbox('setText', ParentName);
            $('#ParentID').val(ParentSymptomCode);
            $('#ID').val(LowerLevelSymptomCode);
            $('#Symptom').textbox('setText', LowerName);

            $.ajax({
                type: 'POST',
                url: '@Url.Content("~/DM/M_ZSymptomPendingInvestigation/GetListByID")',
                data:
                    {
                        ID: $('#ID').val()
                    },
                dataType: "json",
                success: function (jsData) {
                    if (jsData.model.IsActive)
                    { var isa = "有效"; } else {
                        var isa = "无效";
                    };

                    $('#IsActive').combobox('setText', isa);
                    $('#SN').textbox("setText", jsData.model.SN);
                    $('#PinYin').textbox("setText", jsData.model.PinYin);
                    var Isac = jsData.model.IsActive;
                    $('#IsActs').val(Isac);
                }
            });
            $('#M_ZSymptomPendingInvestigationEdit').dialog('open');
            $('#btnedit').linkbutton('enable');
        }
        function submitAddForm() {
            var isValid = $("#M_ZSymptomPendingInvestigationEdit").form("validate");
            if (isValid) {
                $('#btnadd').linkbutton('disable')
                $.ajax({
                    type: 'POST',
                    url: '@Url.Content("~/DM/M_ZSymptomPendingInvestigation/AddSymptom")',
                    data:
                        {
                            PID:$('#ParentID').val(),
                            SymptomName: $('#Symptom').textbox('getText'),
                            IsActive:$('#IsActive').combobox('getValue'),
                            SN:$('#SN').textbox('getText'),
                            PinYin: $('#PinYin').textbox('getText')
                        },
                    dataType: "json",
                    success: function (jsData) {
                        $.handleJsonResult(jsData, function () {
                            initTree()
                            $('#M_ZSymptomPendingInvestigationEdit').window('close');
                        }, function () {
                            $('#btnadd').linkbutton('enable');
                        });
                    }
                });
            }
        }
        function submitEditForm() {
            $('#btnedit').linkbutton('disable')
            $.ajax({
                type: 'POST',
                url: '@Url.Content("~/DM/M_ZSymptomPendingInvestigation/EditSymptom")',
                data:
                    {
                        PID:$('#ParentID').val(),
                        SID:$('#ID').val(),
                        SymptomName: $('#Symptom').textbox('getText'),
                        IsActive: $('#IsActive').combobox('getValue'),
                        SN: $('#SN').textbox('getText'),
                        PinYin: $('#PinYin').textbox('getText'),
                        isAct: $('#IsActs').val()
                    },
                dataType: "json",
                success: function (jsData) {
                    $.handleJsonResult(jsData, function () {
                        initTree()
                        $('#M_ZSymptomPendingInvestigationEdit').window('close');
                    }, function () {
                        $('#btnedit').linkbutton('enable');
                    });
                }
            });
        }

    </script>

}
<div id="TableForm" class="easyui-layout" style="width:auto; height: auto; margin-left: auto; margin-right: auto">
    <div data-options="region:'center',title:'症状待查维护',iconCls:'icon-custom-Surplus'">
        <ul id="M_ZSymptomPendingInvestigationTree"></ul>
        <div id="menu" class="easyui-menu" style="width:150px;">
            <div data-options="iconCls:'icon-custom-Surplus'" onclick="AddSymptomLevel()">添加平级症状待查</div>
            <div data-options="iconCls:'icon-add'" onclick="AddSymptomLowerLevel()">添加下级症状待查</div>
            <div data-options="iconCls:'icon-edit'" onclick="EditSymptomInfo()">修改信息</div>
        </div>
    </div>
</div>

<div id="M_ZSymptomPendingInvestigationEdit" class="easyui-dialog" title="症状待查维护" data-options="modal:true,collapsible:false,minimizable:false,maximizable:false,closed:true,resizable:false,iconCls:'icon-custom-Surplus'" style="width:300px;height:330px;padding:0px;">
    <div data-options="region:'center'" style="overflow: hidden">
        <table style="width:99%">
            <tr style="height:40px">
                <td>上级目录：</td>
                <td>
                    <input id="ParentSymptom" class="easyui-textbox" style="width:160px" data-options="readonly:true" />
                    <input id="ParentID" type="hidden" />
                </td>
            </tr>
            <tr style="height:40px">
                <td>名称：</td>
                <td>
                    <input id="Symptom" class="easyui-textbox" style="width:160px" data-options="required:true" />
                    <input id="ID" type="hidden" />
                </td>
            </tr>
            <tr style="height:40px">
                <td>是否有效：</td>
                <td>
                    <select class="easyui-combobox" style="width: 160px" id="IsActive" data-options="required:true,panelHeight:70,editable:false">
                        <option value="true">有效</option>
                        <option value="false">无效</option>
                    </select>
                    <input id="IsActs" type="hidden" />
                </td>
            </tr>
            <tr style="height:40px">
                <td>顺序号：</td>
                <td>
                    <input id="SN" class="easyui-numberbox" style="width:160px" data-options="required:true" />

                </td>
            </tr>
            <tr style="height:40px">
                <td>拼音头：</td>
                <td>
                    <input id="PinYin" class="easyui-textbox" style="width:160px" />

                </td>
            </tr>
            <tr style="height:40px">
                <td style="width:60px">说明：</td>
                <td>
                    <span style="width:160px">没有子目录的必须填写'拼音头'（拼音首字母小写）,有子目录的不用填</span>

                </td>
            </tr>
            <tr style="height:30px">
                <td colspan="2">
                    <a href="javascript:void(0)" id="btnedit" class="easyui-linkbutton" data-options="iconCls:'icon-edit'" onclick="submitEditForm();">确认修改</a>
                    <a href="javascript:void(0)" id="btnadd" class="easyui-linkbutton" data-options="iconCls:'icon-add'" onclick="submitAddForm();">确认新增</a>
                </td>
            </tr>
        </table>
    </div>
</div>
